package services

import (
	"GOPAAS/internal/app/model"
	"GOPAAS/tools/email"
)

type MailService struct {
	model.IrMailServer
}

func GetMailService(s_id int64) *MailService {
	db = getDB()
	var mail model.IrMailServer
	if s_id > 0 {
		db.First(&mail, s_id)
	}
	return &MailService{mail}
}

func (m *MailService) SendMail(to_email string, content string) (err error) {
	tools_mail := email.GetMail().Init(m.SmtpUser, m.SmtpPass, m.SmtpHost)
	err = tools_mail.SetContent(content).Send([]string{to_email})
	return
}
